package com.chenyun.common.context;
import com.chenyun.common.vo.SessionUser;

/**
 * @descriptions: 存储当前登录用户的上下文类
 * @author: Lonni
 * @date: 2021/1/12 21:59
 * @version: 1.0
 */
public class UserContextHolder {
    /**
     * 存储当前请求的用户信息
     */
    private static final ThreadLocal<SessionUser> USER_THREAD_LOCAL = new InheritableThreadLocal<>();


    public static void putUser(SessionUser user) {
        USER_THREAD_LOCAL.set(user);
    }
    public static void removeUser() {
        USER_THREAD_LOCAL.remove();
    }

    public static SessionUser getUser(){
        return USER_THREAD_LOCAL.get();
    }





}
